<template>
	<view>
		<view class="cu-card article case  " :class="isCard?'no-card':''" v-for="(i,index) in datalist">
			<view class="cu-item  radius shadow-warp bg-white">
				<view class="title">
					<view class="text-cut" style="color: red;">{{i.carNum}}</view>
				</view>
				<view class="content">

					<view class="desc">
						<view class="text-content">{{i.carInfo}}</view>

					</view>
				</view>
			</view>
		</view>
		<view style="padding: 40rpx;">
			<!-- <button class="cu-btn block bg-blue margin-tb-sm lg" @click="add">
				添加车辆
			</button> -->
		</view>
		
	</view>

</template>
<script>
	export default {
		data() {
			return {
				token: '',
				datalist: []
			}

		},
		onLoad() {
			this.token = uni.getStorageSync("token")
			if (this.token == '') {
				uni.showToast({
					title: '请先登录',
					icon: "error"
				});
				uni.navigateTo({
					url: '/pages/login/login'
				})
			}
			let that = this
			uni.request({
				url: "http://127.0.0.1:9000/car/findAllCars",
				method: "post",
				header: {
					Authorization: that.token
				},
				success(res) {

					var rs = res.data.data.cars

					that.datalist = rs
					console.log(rs);

				}
			})
		},
		methods: {
			add(){
				uni.navigateTo({
					url: '../daohang/cars',
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>
<style lang="less">
	.car {
		display: flex;
		justify-content: space-around;
		width: 95%;
		background-color: white;

		.car1 {

			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
		}

		.delete {

			height: 80rpx;
			background-color: aliceblue;
		}
	}
</style>
